package com.xbongbong.pro.rabbitmq.consumer;

import com.xbongbong.pro.enums.smartsettings.enums.AiAssistantPushTypeEnum;
import com.xbongbong.pro.message.pojo.dto.MessageRabbitMqDTO;
import com.xbongbong.pro.rabbitmq.binders.AiAssistantConsumerBinder;
import com.xbongbong.pro.rabbitmq.constant.AiAssistantBinderConstant;
import com.xbongbong.pro.rabbitmq.service.AiAssistantService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.handler.annotation.Header;

import javax.annotation.Resource;
import java.util.Objects;

/**
 * @Author: hongxiao
 * @date: 2019-11-17 14:31
 */
@EnableBinding(AiAssistantConsumerBinder.class)
public class AiAssistantListener {
    private static Logger LOG = LoggerFactory.getLogger(AiAssistantListener.class);

    @Resource
    private AiAssistantService aiAssistantService;

    /**
     * 客户
     */
    @StreamListener(value = AiAssistantBinderConstant.CUSTOMER_INPUT)
    public void customerReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.CUSTOMER_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }

    /**
     * 联系人
     */
    @StreamListener(value = AiAssistantBinderConstant.CONTACT_INPUT)
    public void contactReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.CONTACT_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }

    /**
     * 机会
     */
    @StreamListener(value = AiAssistantBinderConstant.OPPORTUNITY_INPUT)
    public void opportunityReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.OPPORTUNITY_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }

    /**
     * 合同
     */
    @StreamListener(value = AiAssistantBinderConstant.CONTRACT_INPUT)
    public void contractReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.CONTRACT_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }

    /**
     * 退货退款
     */
    @StreamListener(value = AiAssistantBinderConstant.REFUND_INPUT)
    public void refundReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.REFUND_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }

    /**
     * 工作报告
     */
    @StreamListener(value = AiAssistantBinderConstant.WORK_REPORT_INPUT)
    public void workReportReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.WORK_REPORT_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }


    /**
     * 报价单
     */
    @StreamListener(value = AiAssistantBinderConstant.QUOTATION_INPUT)
    public void quotationReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.QUOTATION_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }

    /**
     * 回款
     */
    @StreamListener(value = AiAssistantBinderConstant.PAYMENT_INPUT)
    public void paymentReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.PAYMENT_PLAN_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }

    /**
     * 发票
     */
    @StreamListener(value = AiAssistantBinderConstant.INVOICE_INPUT)
    public void invoiceReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.INVOICE_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }

    /**
     * 付款
     */
    @StreamListener(value = AiAssistantBinderConstant.PAY_PLAN_INPUT)
    public void payPlanReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.PAY_PLAN_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }

    /**
     * 供应商
     */
    @StreamListener(value = AiAssistantBinderConstant.SUPPLIER_INPUT)
    public void supplierReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.SUPPLIER_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }

    /**
     * 供应商联系人
     */
    @StreamListener(value = AiAssistantBinderConstant.SUPPLIER_CONTACT_INPUT)
    public void supplierContactReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.SUPPLIER_CONTACT_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }

    /**
     * 采购合同
     */
    @StreamListener(value = AiAssistantBinderConstant.PURCHASE_INPUT)
    public void purchaseReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.PURCHASE_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }

    /**
     * 采购退货
     */
    @StreamListener(value = AiAssistantBinderConstant.RETURNED_PURCHASE_INPUT)
    public void returnedPurchaseReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.RETURNED_PURCHASE_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }

    /**
     * 出库单
     */
    @StreamListener(value = AiAssistantBinderConstant.OUTSTOCK_INPUT)
    public void outstockReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.OUTSTOCK_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }

    /**
     * 入库单
     */
    @StreamListener(value = AiAssistantBinderConstant.INSTOCK_INPUT)
    public void instockReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.INSTOCK_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }

    /**
     * 装配单
     */
    @StreamListener(value = AiAssistantBinderConstant.ASSEMBLE_INPUT)
    public void assembleReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.ASSEMBLE_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }

    /**
     * 调拔单
     */
    @StreamListener(value = AiAssistantBinderConstant.TRANSFER_INPUT)
    public void transferReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.TRANSFER_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }


    /**
     * 盘点单
     */
    @StreamListener(value = AiAssistantBinderConstant.INVENTORY_INPUT)
    public void inventoryReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.INVENTORY_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }

    /**
     * bom
     */
    @StreamListener(value = AiAssistantBinderConstant.BOM_INPUT)
    public void bomReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.BOMBILL_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }

    /**
     * 生产单
     */
    @StreamListener(value = AiAssistantBinderConstant.PRODUCTION_ORDER_INPUT)
    public void productionOrderReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.PRODUCTION_ORDER_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }

    /**
     * 产品
     */
    @StreamListener(value = AiAssistantBinderConstant.PRODUCT_INPUT)
    public void productReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.PRODUCT_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }

    /**
     * 库存查询
     */
    @StreamListener(value = AiAssistantBinderConstant.PRODUCT_STOCK_INPUT)
    public void productStockReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.PRODUCT_STOCK_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }

    /**
     * 库存预警
     */
    @StreamListener(value = AiAssistantBinderConstant.PRODUCT_STOCK_WARNING_INPUT)
    public void productStockWarningReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.PRODUCT_STOCK_WARNING_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }


    /**
     * 保质期预警
     */
    @StreamListener(value = AiAssistantBinderConstant.PRODUCT_STOCK_GUARANTEE_INPUT)
    public void productStockGuaranteeReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.PRODUCT_STOCK_GUARANTEE_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }

    /**
     * 待采购
     */
    @StreamListener(value = AiAssistantBinderConstant.WAIT_PURCHASE_INPUT)
    public void waitPurchaseReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.WAIT_PURCHASE_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }

    /**
     * 待生产
     */
    @StreamListener(value = AiAssistantBinderConstant.WAIT_PRODUCE_INPUT)
    public void waitProduceReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.WAIT_PRODUCE_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }

    /**
     * 待出库
     */
    @StreamListener(value = AiAssistantBinderConstant.WAIT_OUTSTOCK_INPUT)
    public void waitOutstockReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.WAIT_OUTSTOCK_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }

    /**
     * 待入库
     */
    @StreamListener(value = AiAssistantBinderConstant.WAIT_INSTOCK_INPUT)
    public void waitInstockReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.WAIT_INSTOCK_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }
    /**
     * 市场活动
     */
    @StreamListener(value = AiAssistantBinderConstant.MARKET_ACTIVITY_INPUT)
    public void marketActivityReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.MARKET_ACTIVITY_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }
    /**
     * 销售线索
     */
    @StreamListener(value = AiAssistantBinderConstant.CLUE_INPUT)
    public void clueReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.CLUE_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }

    /**
     * 销售线索
     */
    @StreamListener(value = AiAssistantBinderConstant.PAAS_INPUT)
    public void paasReceive(MessageRabbitMqDTO message, @Header("type") AiAssistantPushTypeEnum type) {

        try {
            if(Objects.equals(AiAssistantPushTypeEnum.PAAS_PUSH, type)) {
                aiAssistantService.insertPushData(message, type);
            }
        } catch (Exception e) {
            LOG.error("SmartSettingsMessageListener Exception, type=" + type, e);
        }
    }
}
